Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

glob

Package Overview
Dependencies
Maintainers
1
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

glob

the most correct and second fastest glob implementation in JavaScript

  • 10.4.5
  • legacy-v10
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
178M
increased by5.73%
Maintainers
1
Weekly downloads
 
Created

What is glob?

The glob npm package allows users to match file paths against specified patterns similar to how shell works. It is widely used for tasks such as file searching, filtering, and bulk operations on sets of files.

What are glob's main functionalities?

File Pattern Matching

Match files using the patterns the shell uses, like stars and stuff.

const glob = require('glob');

glob('**/*.js', function (er, files) {
  // files is an array of filenames.
  // If the `nonull` option is set, and nothing
  // was found, then files is ["**/*.js"]
  // er is an error object or null.
  console.log(files);
});

Synchronous File Pattern Matching

Perform a synchronous glob search.

const glob = require('glob');

const files = glob.sync('**/*.js');
// files is an array of filenames found matching the pattern.
console.log(files);

Pattern Matching with Promises

Use glob with Promises for better async control flow.

const glob = require('glob');
const util = require('util');
const globPromise = util.promisify(glob);

globPromise('**/*.js').then(files => {
  console.log(files);
}).catch(err => {
  console.error('Error occurred:', err);
});

Other packages similar to glob

FAQs

Package last updated on 09 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc